<?xml version="1.0" encoding="utf-8"?>
<!--
                                                                                     
 h       t     t                ::       /     /                     t             / 
 h       t     t                ::      //    //                     t            // 
 h     ttttt ttttt ppppp sssss         //    //  y   y       sssss ttttt         //  
 hhhh    t     t   p   p s            //    //   y   y       s       t          //   
 h  hh   t     t   ppppp sssss       //    //    yyyyy       sssss   t         //    
 h   h   t     t   p         s  ::   /     /         y  ..       s   t    ..   /     
 h   h   t     t   p     sssss  ::   /     /     yyyyy  ..   sssss   t    ..   /     
                                                                                     
	<https://y.st./>
	Copyright © 2016 Alex Yst <mailto:copyright@y.st>

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program. If not, see <https://www.gnu.org./licenses/>.
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<base href="https://y.st./en/weblog/2016/10-October/31.xhtml" />
		<title>A temporary job &lt;https://y.st./en/weblog/2016/10-October/31.xhtml&gt;</title>
		<link rel="icon" type="image/png" href="/link/CC_BY-SA_4.0/y.st./icon.png" />
		<link rel="stylesheet" type="text/css" href="/link/basic.css" />
		<link rel="stylesheet" type="text/css" href="/link/site-specific.css" />
		<script type="text/javascript" src="/script/javascript.js" />
		<meta name="viewport" content="width=device-width" />
	</head>
	<body>
		<nav>
			<p>
				<a href="/en/">Home</a> |
				<a href="/en/a/about.xhtml">About</a> |
				<a href="/en/a/contact.xhtml">Contact</a> |
				<a href="/a/canary.txt">Canary</a> |
				<a href="/en/URI_research/"><abbr title="Uniform Resource Identifier">URI</abbr> research</a> |
				<a href="/en/opinion/">Opinions</a> |
				<a href="/en/coursework/">Coursework</a> |
				<a href="/en/law/">Law</a> |
				<a href="/en/a/links.xhtml">Links</a> |
				<a href="/en/weblog/2016/10-October/31.xhtml.asc">{this page}.asc</a>
			</p>
			<hr/>
			<p>
				Weblog index:
				<a href="/en/weblog/"><abbr title="American Standard Code for Information Interchange">ASCII</abbr> calendars</a> |
				<a href="/en/weblog/index_ol_ascending.xhtml">Ascending list</a> |
				<a href="/en/weblog/index_ol_descending.xhtml">Descending list</a>
			</p>
			<hr/>
			<p>
				Jump to entry:
				<a href="/en/weblog/2015/03-March/07.xhtml">&lt;&lt;First</a>
				<a rel="prev" href="/en/weblog/2016/10-October/30.xhtml">&lt;Previous</a>
				<a rel="next" href="/en/weblog/2016/11-November/01.xhtml">Next&gt;</a>
				<a href="/en/weblog/latest.xhtml">Latest&gt;&gt;</a>
			</p>
			<hr/>
		</nav>
		<header>
			<h1>A temporary job</h1>
			<p>Day 00604: Monday, 2016 October 31</p>
		</header>
<img src="/img/CC_BY-SA_4.0/y.st./weblog/2016/10/31.jpg" alt="Mushrooms in the side yard" class="weblog-header-image" width="811" height="480" />
<p>
	Current countdowns:
</p>
<ul>
	<li>249 scheme-specific <abbr title="Uniform Resource Identifier">URI</abbr>-parsing classes to write and add to <a href="https://git.vola7ileiax4ueow.onion/y.st./include.d/releases">include.d</a></li>
	<li>1 free elective left in my associate degree program</li>
	<li>4 free electives left in my bachelor degree program</li>
</ul>
<p>
	Topics for essays that I want to write outside of school:
</p>
<ul>
<li>How the <abbr title="GNU &quot;Free&quot; Documentation License">GFDL</abbr> isn&apos;t a free license, and is effectively nonfree even when invariant sections aren&apos;t used</li>
<li>How the telephone number system is screwy</li>
<li>How postpaid mobile plans are bad for customers</li>
<li>How connections using &quot;untrusted&quot; <abbr title="Transport Layer Security">TLS</abbr> certificates are more trustworthy than connections without any <abbr title="Transport Layer Security">TLS</abbr> certificate at all</li>
<li>The importance of free software</li>
<li>The importance of free media</li>
</ul>
<p>
	It seems that one of the managers from work called me by telephone yesterday and I didn&apos;t notice.
	I tried to call back, but I can&apos;t figure out how to place calls through Google Voice.
	One option that I found involves having Google Voice call you at another telephone number, then having Google Voice connect your call to the intended party.
	That requires having a voice line though, and thankfully, I don&apos;t have one.
	If using Google Voice required that I have a separate telephone line, what is even the point of having Google Voice service? The other option works through the Web, at least as far as I can tell, but that option requires the installation of a proprietary Web browser plugin.
	Obviously that&apos;s not an option either.
	I ended up using <abbr title="Short Message Service">SMS</abbr> to get back to them.
	Later in the day, the head manager wrote to me via email.
	I explained that I might not be able to stay beyond a month or two, but I got the job anyway! The head manager asked if there was a telephone number that I could be reached at, and I replied that my telephone number is on my resume, but apparently, the head manager already tried that number.
	For some reason, they couldn&apos;t get through.
	I don&apos;t know what Google did wrong that is preventing the call from getting through, but the head manager brushed it off and said that I should just keep an eye on my email inbox.
	Sweet! Last time that I worked there, the same head manager insisted that I not cancel my telephone service because email wasn&apos;t good enough for them.
	This will be a big improvement! On Thursday at 14:00, I&apos;m to bring by the documentation that says that I&apos;m legally allowed to work in this country, then on Friday and Saturday, I work shifts from 08:00 to 12:00 and 16:00 to 19:00, respectively.
</p>
<p>
	I started building <abbr title="PHP: Hypertext Preprocessor">PHP</abbr> classes for parsing <abbr title="Uniform Resource Identifier">URI</abbr>-like strings with the <code>aaas:</code> and <code>aaa:</code> scheme as described by <a href="https://tools.ietf.org./html/rfc6733"><abbr title="Request for Comments">RFC</abbr> 6733</a>, but I ran into a bit of a design difficulty.
	My <abbr title="Uniform Resource Identifier">URI</abbr> parsers and <abbr title="Uniform Resource Identifier">URI</abbr>-like string parsers all extend a base class, <code>\st\y\uri\abstract_class\uri</code>.
	This base class is an abstract class that defines a couple of <code>final</code> and <code>abstract</code> methods.
	The whole point of this class is to allow <abbr title="Uniform Resource Identifier">URI</abbr>-like strings, which don&apos;t quite meet the definition of a <abbr title="Uniform Resource Identifier">URI</abbr> because they don&apos;t conform to <a href="https://tools.ietf.org./html/rfc3986"><abbr title="Request for Comments">RFC</abbr> 3986</a>, to still be mostly treated as <abbr title="Uniform Resource Identifier">URI</abbr>s.
	With that in mind, the <code>\st\y\uri\abstract_class\uri</code> class is defined as containing an <code>abstract</code> method that corresponds to every method present in the base <abbr title="Uniform Resource Identifier">URI</abbr> class, <code>\st\y\uri</code>.
	Any method that the base class has, the abstract class must also have.
	This is by design.
	One method defined in the base class, <code>\st\y\uri::normalize_percent()</code>, doesn&apos;t hold any relevance to <abbr title="Uniform Resource Identifier">URI</abbr>-like strings of the <code>aaas:</code> and <code>aaa:</code> schemes, yet for best compatibility, the abstract class <strong>*must*</strong> call for <code>\st\y\uri\abstract_class\uri::normalize_percent()</code> to be defined.
	In theory, I could move the method definition from the <code>\st\y\uri</code> class to the <code>\st\y\uri\abstract_class\uri</code> class, but that seems hacky.
	It&apos;s true that it&apos;s unlikely that the schemes of <abbr title="Uniform Resource Identifier">URI</abbr>-like strings will call for percent encodings to function differently than in real <abbr title="Uniform Resource Identifier">URI</abbr>s.
	However, it&apos;s also unlikely that a <abbr title="Uniform Resource Identifier">URI</abbr>-like string scheme would call for a host component to be present while also calling for the path component to begin with a non-slash character, but that&apos;s exactly what <abbr title="Request for Comments">RFC</abbr> 6733 does.
	Both actions are equally incorrect, and anything claiming to be a <abbr title="Uniform Resource Identifier">URI</abbr> scheme shouldn&apos;t be making such specifications.
	My other option is to define the method as just a dummy method in <code>\st\y\uri\abstract_class\aaas</code> (a class extended by <code>\st\y\uri\aaas</code> and <code>\st\y\uri\aaa</code>).
	That feels incorrect too though.
	Someone calling that method expects something very specific.
	If I made that method private, it would no longer be an issue, but I&apos;d be blocking access to that method for no valid reason.
	Because of the way that that method is called from within other methods in <code>\st\y\uri</code> (for example, <code>$path = \preg_replace_callback(self::REGEXP_PERCENT, &apos;self::normalize_percent&apos;, $path);</code>), it should be perfectly safe to move it to the abstract class.
	Specifically, the method doesn&apos;t have to be final, as it doesn&apos;t matter if child classes redefine it.
	The correct version will always be referenced by the <code>self</code> keyword.
	With that in mind, I moved the method to the abstract class, at least for now.
	I&apos;m not sure that it&apos;s the best option, but at least it keeps me from being stuck, unable to make progress.
	In a way, any decision as to what to do here is better than no decision.
</p>
<p>
	The next issue that I ran into was the port number validation.
	While <abbr title="Request for Comments">RFC</abbr> 6733 doesn&apos;t conform to <abbr title="Request for Comments">RFC</abbr> 3986, it does still call for port numbers to conform to <abbr title="Request for Comments">RFC</abbr> 3986&apos;s definition.
	The easiest way to check for conformity is to check the port number against the regular expression contained in the <code>\st\y\uri::REGEXP_PORT</code> constant.
	I could copy the value to a constant in the <code>\st\y\uri\abstract_class\aaas</code> class, but that&apos;s always a bad idea.
	I could instead use this constant across classes, but that is a bit messy as well.
	It causes the <code>\st\y\uri</code> class to be loaded in cases where only that constant is needed.
	I ended up moving all regular expression constants from the <code>\st\y\uri</code> class into the <code>\st\y\uri\abstract_class\uri</code> class.
	It&apos;s a bit messy, but I think that it&apos;s the best option.
	It results in all of the basic regular expressions being loaded any time that any class dealing with <abbr title="Uniform Resource Identifier">URI</abbr>s or <abbr title="Uniform Resource Identifier">URI</abbr>-like strings is involved, but most of these will be actual <abbr title="Uniform Resource Identifier">URI</abbr>s, which would have loaded all of those anyway, and many <abbr title="Uniform Resource Identifier">URI</abbr>-like strings could probably use at least some of those regular expressions.
</p>
<p>
	I could have probably finished the classes relating to the two <abbr title="Uniform Resource Identifier">URI</abbr>-like string schemes that I started on today, but I didn&apos;t exactly get to work right away.
	I need to get better about that, especially if I&apos;m going to be employed.
	There isn&apos;t going to be any time to waste.
</p>
<p>
	For quite a while, I&apos;ve been struggling with the decision of whether or not to define my own exception classes in <abbr title="PHP: Hypertext Preprocessor">PHP</abbr>.
	On one side, the built-in exception classes use only integer exception codes.
	How do you choose meaningful integers to use as the exception codes? That can be fixed in descendant classes, as the only thing enforcing the use of numeric exception codes is the <code>__construct()</code> method, which can be overridden.
	Are child classes really warranted though? Furthermore, what can you put in a string-type exception code that would be useful for debugging? The exception code shouldn&apos;t be a full message about what went wrong, as that&apos;s what the exception message is for.
	Until today, I&apos;ve been using the built-in exception classes, using my <code>\st\y\string_to_code()</code> function to pack a short, semi-meaningful string into an integer to use as an exception code and <code>\st\y\code_to_string()</code> to later extract that string.
	I&apos;ve thought that that strategy is a little messy, but I didn&apos;t really know of a better option.
	However, it just occurred how to clean up that mess.
	I need custom exception classes that have that functionality built into them! That way, I can simply instantiate the exception classes using the short strings instead of pre-computing the integers and storing them in class constants defined in the classes that throw the exceptions! This has the added benefit of providing a clean way to deal with exceptions thrown from within non-class functions, as those can&apos;t define associated constants.
	I can also delete the class constants themselves, which are now obsolete, and add the method for extracting the strings as a class method.
	That way, an extra function file doesn&apos;t need to be <code>require</code>d by code that wants to check the exception code properly.
	I&apos;ll probably work on coding up the exception classes tomorrow.
	For compatibility with the built-in exception tree, I&apos;ll need to define my code as several leaves on the exception class family tree instead of as one class that extends the basic <code>\Exception</code> class.
	That way, programmers can still catch different classes of exception properly, distinguishing an <code>\UnderflowException</code> from a <code>\BadMethodCallException</code>.
</p>
<p>
	My <a href="/a/canary.txt">canary</a> still sings the tune of freedom and transparency.
</p>
		<hr/>
		<p>
			Copyright © 2016 Alex Yst;
			You may modify and/or redistribute this document under the terms of the <a rel="license" href="/license/gpl-3.0-standalone.xhtml"><abbr title="GNU&apos;s Not Unix">GNU</abbr> <abbr title="General Public License version Three or later">GPLv3+</abbr></a>.
			If for some reason you would prefer to modify and/or distribute this document under other free copyleft terms, please ask me via email.
			My address is in the source comments near the top of this document.
			This license also applies to embedded content such as images.
			For more information on that, see <a href="/en/a/licensing.xhtml">licensing</a>.
		</p>
		<p>
			<abbr title="World Wide Web Consortium">W3C</abbr> standards are important.
			This document conforms to the <a href="https://validator.w3.org./nu/?doc=https%3A%2F%2Fy.st.%2Fen%2Fweblog%2F2016%2F10-October%2F31.xhtml"><abbr title="Extensible Hypertext Markup Language">XHTML</abbr> 5.1</a> specification and uses style sheets that conform to the <a href="http://jigsaw.w3.org./css-validator/validator?uri=https%3A%2F%2Fy.st.%2Fen%2Fweblog%2F2016%2F10-October%2F31.xhtml"><abbr title="Cascading Style Sheets">CSS</abbr>3</a> specification.
		</p>
	</body>
</html>

